<?php
class filter_listModel extends baseModel{
    protected $table = 'filter_list';

    //属性列表
    public function filter_list($cid) {
        return $this->select('cid='.$cid,'','sequence asc,fid asc');
    }

    //判断重复
    public function filter_info($cid,$urlname,$fid=null) {
        if(!empty($fid)){
            $where=' AND fid<>'.$fid;
        }
        return $this->count('cid='.$cid.' AND urlname="'.$urlname.'"'.$where);
    }

    //属性信息
    public function info($fid) {
        return $this->find('fid='.$fid);
    }

    //添加属性
    public function add($data)
    {

        return $this->insert($data);
    }
    //编辑属性
    public function edit($data)
    {
        $condition['fid']=intval($data['fid']);
        return $this->update($condition,$data); 
    }
    //删除属性
    public function del($fid)
    {
        model('filter')->list_del($fid);
        model('filter_relation')->del_relation($fid);
        return $this->delete('fid='.intval($fid)); 
    }

	
}